package com.javiercp.ayudaapp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.Toast;

public class MainActivity extends Activity {

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Log.i(MyConstants.LOGTAG, "onCreate");
        
        Log.i(MyConstants.LOGTAG, "Setting up UI");
        ImageButton btnMain = (ImageButton)findViewById(R.id.mainBtn);
        btnMain.setOnClickListener(onClickMainBtn);
    }
       
    private final OnClickListener onClickMainBtn = new OnClickListener() {	
		@Override
		public void onClick(View v) {				
            Intent myIntent = new Intent(v.getContext(), SendActivity.class);
            startActivityForResult(myIntent, 0);
		}
	};
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {		
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.main_menu, menu);
		
		return true;
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
			case R.id.settings:			
                Intent settingsActivity = new Intent(getBaseContext(), Preferences.class);
                startActivity(settingsActivity);
				
				return true;
			case R.id.about:
				Toast.makeText(getApplicationContext(), "Quien soy?", Toast.LENGTH_SHORT).show();
	
				return true;
			default:
				return super.onOptionsItemSelected(item);
		}
	}
}